package com.netease.g;

import android.util.Log;
import com.netease.pris.a.e;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Calendar;
import java.util.Vector;

public class b
{
  public static final String a = "NTLog";
  public static boolean b = false;
  public static final int c = 1;
  public static final int d = 16;
  public static final int e = 256;
  public static final int f = 4096;
  public static final int g = 4368;
  static String h;
  static String i;
  public static final int j = 1;
  public static final int k = 2;
  public static a l;
  static Calendar m;
  static StringBuffer n;
  static OutputStream o;
  static long p = 0L;
  private static final String q = "NTLog_log.temp";
  private static final String r = "NTLog_log_last.txt";
  private static final String s = "NTLog_log_now.txt";
  private static final int t = 2;
  private static final int u = 1048576;
  private static Object v = new Object();
  private static final String w = "/data/data/%packetname%/files/";

  static
  {
    l = null;
    m = Calendar.getInstance();
    n = new StringBuffer();
  }

  public static String a()
  {
    if (h != null)
    {
      b("mAppPath lockObj:", "" + v.hashCode());
      b("mAppPath hashCode:", "" + h.hashCode());
    }
    return h;
  }

  private static void a(File paramFile1, File paramFile2, File paramFile3, boolean paramBoolean)
  {
    long l1 = 0L;
    if (paramFile3.exists())
      paramFile3.delete();
    FileOutputStream localFileOutputStream = new FileOutputStream(paramFile3);
    byte[] arrayOfByte = new byte[10240];
    if (paramFile1.exists())
    {
      long l3 = paramFile1.length();
      FileInputStream localFileInputStream2 = new FileInputStream(paramFile1);
      long l4 = l1;
      while (l4 < l3)
      {
        int i2 = localFileInputStream2.read(arrayOfByte);
        localFileOutputStream.write(arrayOfByte, 0, i2);
        l4 += i2;
      }
      localFileInputStream2.close();
    }
    if (paramFile2.exists())
    {
      long l2 = paramFile2.length();
      FileInputStream localFileInputStream1 = new FileInputStream(paramFile2);
      while (l1 < l2)
      {
        int i1 = localFileInputStream1.read(arrayOfByte);
        localFileOutputStream.write(arrayOfByte, 0, i1);
        l1 += i1;
      }
      localFileInputStream1.close();
    }
    localFileOutputStream.close();
  }

  public static void a(String paramString)
  {
    b("NTLog", paramString);
  }

  public static void a(String paramString1, String paramString2)
  {
    synchronized (v)
    {
      h = "/data/data/%packetname%/files/".replaceFirst("%packetname%", paramString1);
      i = paramString2;
      File localFile = new File(h);
      if (!localFile.exists())
        localFile.mkdir();
      return;
    }
  }

  protected static void a(String paramString1, String paramString2, int paramInt1, int paramInt2)
  {
    if (paramString1 == null)
      paramString1 = "TAG_NULL";
    if (paramString2 == null)
      paramString2 = "MSG_NULL";
    if (paramInt2 >= 2)
    {
      if ((paramInt1 & 0x1) != 0)
        b(paramString1, paramString2, paramInt2);
      if ((paramInt1 & 0x10) != 0)
        d(paramString1, paramString2, paramInt2);
      if (((paramInt1 & 0x1000) != 0) && (l == null))
      {
        b localb = new b();
        localb.getClass();
        l = new a(localb);
        l.start();
      }
      if ((paramInt1 & 0x100) != 0)
        c(paramString1, paramString2, paramInt2);
    }
  }

  public static File b(String paramString)
  {
    if ((h == null) || (h.length() == 0));
    for (File localFile = null; ; localFile = new File(h + paramString))
      return localFile;
  }

  public static void b(String paramString1, String paramString2)
  {
    a(paramString1, paramString2, 4368, 3);
  }

  private static void b(String paramString1, String paramString2, int paramInt)
  {
    switch (paramInt)
    {
    default:
    case 3:
    case 6:
    case 4:
    case 2:
    case 5:
    }
    while (true)
    {
      return;
      Log.d(paramString1, paramString2);
      continue;
      Log.e(paramString1, paramString2);
      continue;
      Log.i(paramString1, paramString2);
      continue;
      Log.v(paramString1, paramString2);
      continue;
      Log.w(paramString1, paramString2);
    }
  }

  public static String[] b()
  {
    String[] arrayOfString;
    if ((h != null) && (h.length() > 0))
    {
      Vector localVector = new Vector();
      File localFile1 = b("NTLog_log_last.txt");
      if (localFile1.exists())
        localVector.addElement(localFile1.getAbsolutePath());
      File localFile2 = b("NTLog_log_now.txt");
      if (localFile2.exists())
        localVector.addElement(localFile2.getAbsolutePath());
      if (localVector.size() > 0)
      {
        arrayOfString = new String[localVector.size()];
        localVector.copyInto(arrayOfString);
      }
    }
    while (true)
    {
      return arrayOfString;
      arrayOfString = null;
    }
  }

  public static void c()
  {
    synchronized (v)
    {
      if (l == null)
      {
        b localb = new b();
        localb.getClass();
        l = new a(localb);
        l.start();
      }
      return;
    }
  }

  public static void c(String paramString1, String paramString2)
  {
    a(paramString1, paramString2, 4368, 2);
  }

  private static void c(String paramString1, String paramString2, int paramInt)
  {
    while (true)
    {
      synchronized (v)
      {
        OutputStream localOutputStream = f();
        if (localOutputStream != null)
          try
          {
            byte[] arrayOfByte = g(paramString1, paramString2).getBytes("utf-8");
            if (p >= 1048576L)
              continue;
            localOutputStream.write(arrayOfByte);
            localOutputStream.write("\r\n".getBytes());
            localOutputStream.flush();
            p += arrayOfByte.length;
            return;
            g();
            h();
            c(paramString1, paramString2, paramInt);
            continue;
          }
          catch (Exception localException)
          {
            localException.printStackTrace();
            continue;
          }
      }
      Log.w("RpmmsLog", "Log File open fail: [AppPath]=" + h + ",[LogName]:" + i);
    }
  }

  public static boolean c(String paramString)
  {
    e();
    File localFile = b(paramString);
    if (localFile.exists())
      localFile.delete();
    try
    {
      localFile.createNewFile();
      bool = e.a(b("NTLog_log_now.txt"), localFile);
      return bool;
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localIOException.printStackTrace();
        boolean bool = false;
      }
    }
  }

  public static void d()
  {
    if (l != null)
    {
      l.a();
      l = null;
    }
  }

  public static void d(String paramString1, String paramString2)
  {
    a(paramString1, paramString2, 4368, 6);
  }

  private static void d(String paramString1, String paramString2, int paramInt)
  {
  }

  public static void e()
  {
    try
    {
      synchronized (v)
      {
        g();
        File localFile = b("NTLog_log_now.txt");
        if (localFile.exists())
          localFile.delete();
        try
        {
          localFile.createNewFile();
          a(b("NTLog_log_last.txt"), b("NTLog_log.temp"), localFile, true);
          f();
          return;
        }
        catch (IOException localIOException2)
        {
          while (true)
            localIOException2.printStackTrace();
        }
      }
    }
    catch (IOException localIOException1)
    {
      while (true)
      {
        localIOException1.printStackTrace();
        Log.w("RpmmsLog", "backLogFile fail:" + localIOException1.toString());
      }
    }
  }

  public static void e(String paramString1, String paramString2)
  {
    a(paramString1, paramString2, 4368, 4);
  }

  private static OutputStream f()
  {
    OutputStream localOutputStream = null;
    if (o == null);
    try
    {
      if ((h != null) && (h.length() != 0))
      {
        File localFile = b("NTLog_log.temp");
        if (localFile != null)
        {
          if (localFile.exists())
          {
            o = new FileOutputStream(localFile, true);
            p = localFile.length();
          }
          while (true)
          {
            localOutputStream = o;
            break;
            o = new FileOutputStream(localFile);
            p = 0L;
          }
        }
      }
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      while (true)
        localFileNotFoundException.printStackTrace();
    }
    catch (IOException localIOException)
    {
      while (true)
        localIOException.printStackTrace();
    }
    return localOutputStream;
  }

  public static void f(String paramString1, String paramString2)
  {
    a(paramString1, paramString2, 4368, 5);
  }

  private static String g(String paramString1, String paramString2)
  {
    m.setTimeInMillis(System.currentTimeMillis());
    n.setLength(0);
    n.append("[");
    n.append(paramString1);
    n.append(" : ");
    n.append(1 + m.get(2));
    n.append("-");
    n.append(m.get(5));
    n.append(" ");
    n.append(m.get(11));
    n.append(":");
    n.append(m.get(12));
    n.append(":");
    n.append(m.get(13));
    n.append(":");
    n.append(m.get(14));
    n.append("] ");
    n.append(paramString2);
    return n.toString();
  }

  private static void g()
  {
    try
    {
      if (o != null)
      {
        o.close();
        o = null;
        p = 0L;
      }
      return;
    }
    catch (Exception localException)
    {
      while (true)
        localException.printStackTrace();
    }
  }

  private static void h()
  {
    synchronized (v)
    {
      File localFile1 = b("NTLog_log.temp");
      File localFile2 = b("NTLog_log_last.txt");
      if (localFile2.exists())
        localFile2.delete();
      localFile1.renameTo(localFile2);
      return;
    }
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.g.b
 * JD-Core Version:    0.6.0
 */